package com.zz.zzc;
import java.util.Scanner;
/**
 * 
 * @author zzc20
 *boolean类型的变量是基本类型
 *变量的值只有两种可能：true,false
 */
public class BooleanDemo {

	public static void main(String[] args) {
		/**
		 * 
		 */
		boolean flag = false;
		boolean flag2 = true;
		
		//if(boolean类型的变量){条件真运行}
		if(flag2) {
			System.out.println(flag2);
		}
		
		//关系运算符
		//关系运算结果boolean类型
		int a = 12;
		int b = 1;
		System.out.println(a > b ? a : b);
		System.out.println(a > b);
		System.out.println(a < b);
		System.out.println(a == b);
		System.out.println(a != b);
		
		if(a > b)
			System.out.println("a>b真");
		
		Scanner input = new Scanner(System.in);
		int c = 80;
		/*do {
			c = input.nextInt();
			System.out.println(grade(c));
		}while(c > 0);*/
		
		System.out.println(2 > 1 ? 102 : 99);
		//鸡2、狗4、螃蟹8
		/**
		 * 判断两个字符串是否相等 equals
		 */
		String animal = null;
		do {
			animal = input.next();
			System.out.println(animal + "有" + cal(animal) + "条腿");
		}while(! "0".equals(animal));
	}
	
	
	
	private static String grade(int c) {
		/**
		 * 逻辑运算结果一定是boolean
		 * &&并且
		 * a&&b,必须a,b都是真
		 */
		/*String result = "D";
		if(c < 60) {
			result = "D";
		}else if(c < 80) {
			result = "C";
		}else if(c < 90) {
			result = "B";
		}else
			result = "A";
		return result;*/
		/**
		 * 三元运算符
		 * a?结果1：结果2
		 * a为真结果1，a为假结果2
		 */
		//代码精简不要冗余
		return c < 60 ? "D" : c < 80 ? "C" : c < 90 ? "B" : "A"; 
	}
	
	public static int cal(String animal) {
		return animal.equals("鸡") ? 2 : animal.equals("狗") ? 4 : animal.equals("螃蟹") ? 8 : 0;
	}
	
}
